<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <div class="error-icon">
        <el-icon size="120" color="#E6A23C">
          <WarningFilled />
        </el-icon>
      </div>
      
      <div class="error-text">
        <h1 class="error-code">404</h1>
        <h2 class="error-title">页面不存在</h2>
        <p class="error-description">
          抱歉，您访问的页面不存在或已被删除
        </p>
      </div>
      
      <div class="error-actions">
        <el-button type="primary" size="large" @click="goHome">
          返回首页
        </el-button>
        <el-button size="large" @click="goBack">
          返回上页
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { WarningFilled } from '@element-plus/icons-vue'
import { useUserStore } from '@/stores/user'
import { useAppStore } from '@/stores/app'

const router = useRouter()
const userStore = useUserStore()
const appStore = useAppStore()

// 返回首页
const goHome = () => {
  if (userStore.isLoggedIn) {
    if (userStore.isStudent) {
      router.push('/student')
    } else {
      router.push('/teacher')
    }
  } else {
    router.push('/login')
  }
}

// 返回上一页
const goBack = () => {
  router.go(-1)
}

// 设置页面标题
appStore.setPageTitle('页面不存在')
</script>

<style scoped>
.not-found-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 2rem;
}

.not-found-content {
  text-align: center;
  max-width: 600px;
}

.error-icon {
  margin-bottom: 2rem;
}

.error-text {
  margin-bottom: 3rem;
}

.error-code {
  font-size: 8rem;
  font-weight: 900;
  color: #E6A23C;
  margin: 0;
  line-height: 1;
  text-shadow: 0 4px 8px rgba(230, 162, 60, 0.3);
}

.error-title {
  font-size: 2.5rem;
  font-weight: 600;
  color: #303133;
  margin: 1rem 0;
}

.error-description {
  font-size: 1.1rem;
  color: #909399;
  margin: 0;
  line-height: 1.6;
}

.error-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .error-code {
    font-size: 6rem;
  }
  
  .error-title {
    font-size: 2rem;
  }
  
  .error-description {
    font-size: 1rem;
  }
  
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .error-actions .el-button {
    width: 200px;
  }
}
</style>